package cn0625;

public class Demo {
    //交换两个变量的值
//    public void change(int a,int b){
//        int temp = a;
//        a = b;
//        b = temp;
//        System.out.println("方法内部:"+a+":"+b);
//    }
    public void change(Person p){
        p.name = "郭靖";
    }

    public static void main(String[] args) {
        //测试值传递
//        int a =10;
//        int b =20;
//        System.out.println("交换前：a="+a+",b="+b);
//        Demo d = new Demo();
//        d.change(a,b);
//        System.out.println("交换后：a:="+a+",b="+b);
        //测试引用传递
        Demo r = new Demo();
        Person p = new Person("张无忌");
        System.out.println(p.name);
        r.change(p);
        System.out.println(p.name);
    }
}
